Skip to main content

All Questions

Tagged with
0votes
1answer
494views

php exec/shell_exec behavior CLI vs CGI

I am trying to use php to run some system commands and am getting a behaviour that I don't fully understand. If the php script is run from the command line I get the results I expect. But running it ...
Gavin Murphy's user avatar
0votes
1answer
5kviews

Execute an shell script with sudo inside from php

I want to execute a command line command as root from a php file. In my case I want to view the crontab file in my php page. Running the sudo command in php is not recommended and on my raspberry pi ...
MacQwerty's user avatar
1vote
1answer
228views

Issues with bash script containing exigrep command when invoked from PHP webpage

I have a bash script to extract information from exim_mainlog. When the bash script is run from a putty command line (logged in as root), the extracted data is properly written to an output file. ...
Mike A's user avatar
0votes
0answers
148views

Mount does not work in script when run by php

So I have a script that's placed in my apache2 html folder and should be executed by an http post. The script requires root (I know that's not safe at all, ignore that please), so I set the user www-...
Monocito's user avatar
0votes
0answers
1kviews

PHP shell_exec to run debian system service

I'm trying to control a system service with PHP's shell_exec function : shell_exec('sudo /usr/sbin/service icecast2 stop'); But the only way I can get it to work is by allowing ALL users root access ...
spice's user avatar
-1votes
1answer
83views

Understanding exec

I need to understand the following script sequence. $command .= "n\n\n\n\nt\n7\nc\nw\n"; exec("echo -e \"{$command}\" | /sbin/fdisk {$kernelDevice}"); I can't figure out which ...
peter9999's user avatar
0votes
1answer
547views

exec in php does not work

I'm running apache with php 7.0 on a raspberry pi 3. When I use the curl command on the command line, it works great. But when I use this command in my PHP code, it does nothing. Any idea what this ...
Refilon's user avatar
2votes
1answer
5kviews

Find only in directories n levels deep

I use this command to find and run all istances of wp-cron.php I have for each site I have: find /var/www/ -name 'wp-cron.php' -exec php -q "{}" \; Since my websites tree is: /var/www/site1/htdocs/...
MultiformeIngegno's user avatar
2votes
0answers
712views

PHP exec and amixer

I'm trying to make php lower the dB level of amixer using exec, but it seems like php isn't able to perform the task which requires sudo-access. What should be the best way to solve this? I tried: ...
Tommie Michael Lagerroos's user avatar
0votes
3answers
2kviews

Bash in php exec in webpage don't colors for png and mp3 files on Linux

I have code like this in php: header("Content-Type: text/plain"); exec("/bin/bash -c 'ls --color=always'", $result); echo implode("\n", $result); and I've got result (escape is not visible) Makefile ...
jcubic's user avatar
  • 10.2k
20votes
6answers
165kviews

php shell_exec() permission on Linux Ubuntu

I'm developing a php application using Linux server. My problem is executing shell_exec() to call some exe file is not work(actually not exe, it's kind of linux executable file) echo shell_exec("...
ngoaho91's user avatar
1vote
2answers
7kviews

PHP exec command has the result 0 even if an error occurs

I have this PHP code: $execout=exec('ssh [email protected] "sudo /etc/init.d/smokeping reload"',$output1,$result); if($result !=0){ echo"that can't reload"; } else{ echo "successfully ...
Thusitha Sumanadasa's user avatar

close